package com.xhu.service.impl;

import com.xhu.bean.pojo.Forecast;
import com.xhu.dao.ForecastDao;
import com.xhu.dao.impl.ForecastDaoImpl;
import com.xhu.service.ForecastService;

import java.util.Date;
import java.util.List;

public class ForecastServiceImpl implements ForecastService {

    private ForecastDao forecastDao=new ForecastDaoImpl();
    @Override
    public boolean add(Forecast forecast) {
        forecast.setCreate_Time(new Date());
        return forecastDao.add(forecast)>0;
    }


    @Override
    public Forecast findById(Integer id) {
        return forecastDao.findById(id);
    }

    @Override
    public boolean update(Forecast forecast) {
        return forecastDao.update(forecast)>0;
    }

    @Override
    public boolean deleteById(Integer id) {
        return forecastDao.deleteById(id)>0;
    }

    @Override
    public boolean batchDelete(String ids) {
        return forecastDao.batchDelete(ids)>0;
    }

    @Override
    public boolean findByMonth(String month) {
        Forecast   forecast=forecastDao.findByMonth(month);
        return forecast!=null;
    }

    @Override
    public List<Forecast> findAll() {
        return forecastDao.findAll();
    }

    @Override
    public List<Forecast> queryPage(Integer page, Integer limit, String name) {
        Integer start=(page-1)*limit;
        return forecastDao.querPage(start,limit,name);
    }
}
